package com.forekenow.Demo14;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        DBUtil dbUtil = new DBUtil();
        Connection conn = dbUtil.getConnection();
        List<GuestBook> list = dbUtil.select(conn);
        for (int i = 0; i < list.size(); i++) {
            GuestBook guestBook = list.get(i);
           System.out.println(guestBook.getId()+"---"+guestBook.getName()+"---"+guestBook.getPhone()+"---"+guestBook.getEmail()+"---"+guestBook.getContent());

        dbUtil.insert(conn);
        System.out.println("请输入要删除的id");
        Scanner scanner = new Scanner(System.in);
        int de = scanner.nextInt();
        try {
                dbUtil.delete(conn,de);
            } catch (SQLException e) {
                e.printStackTrace();
             }

            System.out.println("请输入要修改id以及修改后的iPhone");
            Scanner scanner2 = new Scanner(System.in);
            int phone = scanner2.nextInt();
            Scanner scanner1 = new Scanner(System.in);
            int id = scanner1.nextInt();
            try {
                dbUtil.update(conn, id, phone);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}




